{subtemplate template/common/com_header.html}
<script type='text/javascript' src='./template/js/jquery1.8.js'></script>
<script type="text/javascript" src="./template/js/ajaxfileupload.js"></script>
<script type='text/javascript'>
  function upload(){
	  $.ajaxFileUpload({
		    url:'?m=photos&a=upload&s=set',
		    fileElementId:'photoSet',
		    dataType:'json',
		    success:function(feed){
		        var obj=$('#viewSet');
		        var html=obj.html()+'<img width="100" height="100" src="'+feed.img+'" />&nbsp;&nbsp;';
                obj.html(html);
            }
		  });
	  return false;
  }

  function upload2(){
      $.ajaxFileUpload({
          url:'?m=photos&a=upload&s=logo',
          fileElementId:'photoLogo',
          dataType:'json',
          success:function(feed){
              var obj=$('#viewLogo');
              var html='<img width="100" height="100" src="'+feed.img+'" />&nbsp;&nbsp;';
              obj.html(html);
          }
        });
    return false;

  }
$(function(){
	$('form:first').submit(function(){
		var value=new Array();
        $('#viewSet').children().each(function(index){
            value[index]=$(this).attr('src');
        });
        $(':input[name="imgSet"]').attr('value',value);
        value=new Array();
        $('#viewLogo').children().each(function(index){
            value[index]=$(this).attr('src');
        });
        $(':input[name="imgLogo"]').attr('value',value);
        //$(':input').each(function(){alert($(this).attr('value'));});
        return true;
		
    });

    $('.topcate').each(function(){
         $(this).click(function(){
             var idex=$(this).attr('value');
             var cked=$(this).attr('checked');
             var subObj=$('.subcate'+idex);
             if(cked=='checked'){
                 subObj.each(function(){
                     $(this).removeAttr('disabled');
                 });
             }else{
            	 subObj.each(function(){
                	 $(this).attr('disabled','disabled');
                	 $(this).removeAttr('checked');
            	 });
             }
             
         });
    });
});
$.delImg=function(){$('#viewSet img').last().remove();};
</script>

<div class="subcate"><a href="?m=photos" class="img curr" >图片管理</a><a href="?m=photos&a=category" class="cate">分类管理</a></div>
<style type="text/css">
  table{
    border:1px solid #ccc;
  }
  table td{
    border:1px solid #ccc;
  } 
</style>
<form action='?m=photos&a=doAdd' method='post'>
<table border='0' width='100%' cellspacing='0' cellpadding='0'>
  <tr><td>图片名称：</td><td><input type='text' size='20' name='name' /></td></tr>
  {loop $cates $ck $cv}
  <tr>
     <td><input type="checkbox" name="cate[]" value="{$ck}" class="topcate" />{$cv['title']}</td>
     <td>{loop $cv['sub'] $sk $sv}<input type="checkbox" name='cate[]' value="{$sk}"  disabled="" class='subcate{$ck}' />{$sv}&nbsp;&nbsp;{/loop}</td>
  </tr>
  {/loop}
  <tr><td>图片预览：</td><td id='viewSet'>&nbsp;</td></tr>
  <tr><td>上传图片：</td>
      <td><input type='file' name='photoSet' id='photoSet' />&nbsp;&nbsp;
          <input type="button" value='上传' onclick="javascript:upload();" />&nbsp;&nbsp;
          <input type='button' value='删除图片' onclick='javascript:$.delImg();' />
          <input type='hidden' name='imgSet' />
      </td>
 </tr>
  <tr><td>小图预览：</td><td id='viewLogo'>&nbsp;</td></tr>
  <tr><td>小图：</td>
      <td><input type="file" name="photoLogo" id='photoLogo' />&nbsp;&nbsp;
          <input type="button" value="上传" onclick='javascript:upload2();' />
          <input type="hidden" name='imgLogo' />
      </td>
  </tr>
  <!--tr><td>加入专题：</td>
      <td>
        <select name='special'>
          <option value="0">请选择</option>
          {loop $sp $sv}
             <option value="{$sv['id']}">{$sv['sp_name']}</option>
          {/loop}
        </select>
      </td>
 </tr-->
 <tr><td>是否推荐：</td><td><input type='radio' name='recommend' value='1' />是&nbsp;&nbsp;<input type='radio' name='recommend' value='0' />否</td></tr>
 <tr><td>适用脸型：</td>
     <td>{loop $ft $fk $fv}<input type="checkbox" name='faceType[]' value='{$fk|add}' />{$fv}&nbsp;&nbsp;{/loop}</td>
 </tr>
 <tr><td>图片介绍：</td><td><textarea rows='2' cols='80' name='intro'></textarea></td></tr>
 <tr><td>x:</td><td><input type='text' name='xcoord' size="20" /></td></tr>
 <tr><td>y:</td><td><input type='text' name='ycoord' size="20" /></td></tr>
 <tr><td colspan='2'><input type='submit' value='添加'  />&nbsp;&nbsp;<input type='reset' value='取消' /></td></tr>
</table>
</form>
<!--div class="imgInfo">
<form action='?m=photos&a=add' method='post' enctype='multipart/form-data'>
  <div class="img_detail">
    <div class='img_title'>
               图片名称：<input type="text" name="imgname" size="20">
              类型：<select name='type'>
         {loop $cons_type $cons_k $cons_v}
		 <option value="{$cons_k}">{$cons_v}</option>
		 {/loop}
       </select>
       </div>
       
     <div >
       <span style='float:left;'>图片预览：</span>
       <div style="float:left;">
         <ul>
           <li>&nbsp;</li>
           <li ><input type='file' name='userfile' id="userfile" /> &nbsp;<input type='button' value="上传" onclick="javascript:return upload();" /></li>
           <li >图片介绍：</li>
           <li ><textarea rows='5' cols='80'></textarea></li>
           <li >图集介绍：</li>
           <li ><textarea rows='5' cols='80'></textarea></li>
           <li>&nbsp;</li>
           <li><input type='submit' value='确认提交' />&nbsp;<input type="reset" value="取消" /></li>
         </ul>
       </div>
    </div>
  </div>
  </form>
  
</div-->




{subtemplate template/common/com_footer.html}